package com.truiton.screencapture;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

/**
 * Created by ABC on 15/11/16.
 */
public class DialogUtils {
    public static AlertDialog dialog = null;

    public static void showCommonDialog(Context context, String title, String message, DialogInterface.OnClickListener onClickListener) {
        showCommonDialog(context, title, message, "确定", "取消", onClickListener);
    }

    public static void showCommonDialog(Context context, String title, String message, String
            positive, String negative, DialogInterface.OnClickListener onClickListener) {
        showCommonDialog(context, 0, title, message, positive, negative, onClickListener);
    }

    public static void showCommonDialog(Context context, int theme, String title, String message,
                                        String positive, String negative, DialogInterface
                                                .OnClickListener onClickListener) {
        AlertDialog.Builder builder = null;
        if (theme == 0) {
            builder = new AlertDialog.Builder(context);
        } else {
            builder = new AlertDialog.Builder(context, theme);
        }
        builder.setTitle(title);
        builder.setMessage(message);
        if (positive != null) {
            builder.setPositiveButton(positive, onClickListener);
        }
        if (negative != null) {
            builder.setNegativeButton(negative, null);
        }
        builder.show();
    }

    public static void showCommonDialog(Context context, int theme, String title, String message, String
            positive, String negative, DialogInterface.OnClickListener OkListener,
                                        DialogInterface.OnClickListener CancelListener, boolean cancelable) {
        AlertDialog.Builder builder = null;
        if (theme == 0) {
            builder = new AlertDialog.Builder(context);
        } else {
            builder = new AlertDialog.Builder(context, theme);
        }
        builder.setTitle(title);
        builder.setMessage(message);
        builder.setCancelable(cancelable);
        if (positive != null) {
            builder.setPositiveButton(positive, OkListener);
        }
        if (negative != null) {
            builder.setNegativeButton(negative, CancelListener);
        }
        builder.show();
    }


}
